pip install google-api-python-client
Requirement already satisfied: google-api-python-client in c:\programdata\anaconda3\lib\site-packages (2.113.0) Requirement already satisfied: httplib2<1.dev0,>=0.15.0 in c:\programdata\anaconda3\lib\site-packages (from google-api-python-client) (0.22.0) Requirement already satisfied: google-auth<3.0.0.dev0,>=1.19.0 in c:\programdata\anaconda3\lib\site-packages (from google-api-python-client) (2.26.2) Requirement already satisfied: google-auth-httplib2>=0.1.0 in c:\programdata\anaconda3\lib\site-packages (from google-api-python-client) (0.2.0) Requirement already satisfied: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5 in c:\programdata\anaconda3\lib\site-packages (from google-api-python-client) (2.15.0) Requirement already satisfied: uritemplate<5,>=3.0.1 in c:\programdata\anaconda3\lib\site-packages (from google-api-python-client) (4.1.1) Requirement already satisfied: googleapis-common-protos<2.0.dev0,>=1.56.2 in c:\programdata\anaconda3\lib\site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client) (1.62.0) Requirement already satisfied: protobuf!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0.dev0,>=3.19.5 in c:\programdata\anaconda3\lib\site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client) (4.25.2) Requirement already satisfied: requests<3.0.0.dev0,>=2.18.0 in c:\programdata\anaconda3\lib\site-packages (from google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client) (2.31.0) Requirement already satisfied: cachetools<6.0,>=2.0.0 in c:\programdata\anaconda3\lib\site-packages (from google-auth<3.0.0.dev0,>=1.19.0->google-api-python-client) (5.3.2) Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\programdata\anaconda3\lib\site-packages (from google-auth<3.0.0.dev0,>=1.19.0->google-api-python-client) (0.2.8) Requirement already satisfied: rsa<5,>=3.1.4 in c:\programdata\anaconda3\lib\site-packages (from google-auth<3.0.0.dev0,>=1.19.0->google-api-python-client) (4.9) Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in c:\programdata\anaconda3\lib\site-packages (from httplib2<1.dev0,>=0.15.0->google-api-python-client) (3.0.9) Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\programdata\anaconda3\lib\site-packages (from pyasn1-modules>=0.2.1->google-auth<3.0.0.dev0,>=1.19.0->google-api-python-client) (0.4.8) Requirement already satisfied: charset-normalizer<4,>=2 in c:\programdata\anaconda3\lib\site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client) (2.0.4) Requirement already satisfied: idna<4,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client) (3.4) Requirement already satisfied: urllib3<3,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client) (1.26.16) Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests<3.0.0.dev0,>=2.18.0->google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0.dev0,>=1.31.5->google-api-python-client) (2023.11.17) Note: you may need to restart the kernel to use updated packages.
pip install plotly
Requirement already satisfied: plotly in c:\programdata\anaconda3\lib\site-packages (5.18.0) Requirement already satisfied: tenacity>=6.2.0 in c:\programdata\anaconda3\lib\site-packages (from plotly) (8.2.2) Requirement already satisfied: packaging in c:\programdata\anaconda3\lib\site-packages (from plotly) (23.0) Note: you may need to restart the kernel to use updated packages.
import googleapiclient.discovery
import pandas as pd
import matplotlib as pt
import numpy as np
import altair as alt
alt.data_transformers.enable('default', max_rows=None)
from altair import Chart, X, Y, Color, Scale
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
from bs4 import BeautifulSoup
ISO = []
for i in yt["Country"]:
if i == "USA":
ISO.append("USA")
elif i == "CANADA":
ISO.append("CAN")
elif i == "UK":
ISO.append("GBR")
elif i == "FRANCE":
ISO.append("FRA")
elif i == "DENMARK":
ISO.append("DNK")
elif i == "INDIA":
ISO.append("IND")
elif i == "JAPAN":
ISO.append("JPN")
elif i == "SOUTH KOREA":
ISO.append("KOR")
elif i == "MEXICO":
ISO.append("MEX")
elif i == "RUSSIA":
ISO.append("RUS")
else:
ISO.append("")
yt["ISO"] = ISO
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[5], line 3 1 ISO = [] ----> 3 for i in yt["Country"]: 4 if i == "USA": 5 ISO.append("USA") NameError: name 'yt' is not defined
from datetime import datetime
def changedate_formate(yt):
split = yt.split('.')
a = split[1]
b = split[2]
c = split[0]
''.join(a+b+c)
return
yt.info() #The trending date format can now be calculated
yt.dropna(inplace = True)
print(yt.isna().sum())
print(yt.shape)
usa = pd.read_csv("D:\Odin class\youtube/USvideos.csv", encoding = "ISO-8859-1")
country = []
for i in usa["video_error_or_removed"]:
if i == "FALSE":
country.append("United States of America")
else:
country.append("USA")
usa["Country"] = country
usa.head(10)
| video_id | trending_date | title | channel_title | category_id | publish_time | tags | views | likes | dislikes | comment_count | thumbnail_link | comments_disabled | ratings_disabled | video_error_or_removed | description | Country | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2kyS6SvSYSE | 17.14.11 | WE WANT TO TALK ABOUT OUR MARRIAGE | CaseyNeistat | 22 | 2017-11-13T17:13:01.000Z | SHANtell martin | 748374 | 57527 | 2966 | 15954 | https://i.ytimg.com/vi/2kyS6SvSYSE/default.jpg | False | False | False | SHANTELL'S CHANNEL - https://www.youtube.com/s... | USA |
| 1 | 1ZAPwfrtAFY | 17.14.11 | The Trump Presidency: Last Week Tonight with J... | LastWeekTonight | 24 | 2017-11-13T07:30:00.000Z | last week tonight trump presidency|"last week ... | 2418783 | 97185 | 6146 | 12703 | https://i.ytimg.com/vi/1ZAPwfrtAFY/default.jpg | False | False | False | One year after the presidential election, John... | USA |
| 2 | 5qpjK5DgCt4 | 17.14.11 | Racist Superman | Rudy Mancuso, King Bach & Le... | Rudy Mancuso | 23 | 2017-11-12T19:05:24.000Z | racist superman|"rudy"|"mancuso"|"king"|"bach"... | 3191434 | 146033 | 5339 | 8181 | https://i.ytimg.com/vi/5qpjK5DgCt4/default.jpg | False | False | False | WATCH MY PREVIOUS VIDEO ⶠ\n\nSUBSCRIBE ⺠... | USA |
| 3 | puqaWrEC7tY | 17.14.11 | Nickelback Lyrics: Real or Fake? | Good Mythical Morning | 24 | 2017-11-13T11:00:04.000Z | rhett and link|"gmm"|"good mythical morning"|"... | 343168 | 10172 | 666 | 2146 | https://i.ytimg.com/vi/puqaWrEC7tY/default.jpg | False | False | False | Today we find out if Link is a Nickelback amat... | USA |
| 4 | d380meD0W0M | 17.14.11 | I Dare You: GOING BALD!? | nigahiga | 24 | 2017-11-12T18:01:41.000Z | ryan|"higa"|"higatv"|"nigahiga"|"i dare you"|"... | 2095731 | 132235 | 1989 | 17518 | https://i.ytimg.com/vi/d380meD0W0M/default.jpg | False | False | False | I know it's been a while since we did this sho... | USA |
| 5 | gHZ1Qz0KiKM | 17.14.11 | 2 Weeks with iPhone X | iJustine | 28 | 2017-11-13T19:07:23.000Z | ijustine|"week with iPhone X"|"iphone x"|"appl... | 119180 | 9763 | 511 | 1434 | https://i.ytimg.com/vi/gHZ1Qz0KiKM/default.jpg | False | False | False | Using the iPhone for the past two weeks -- her... | USA |
| 6 | 39idVpFF7NQ | 17.14.11 | Roy Moore & Jeff Sessions Cold Open - SNL | Saturday Night Live | 24 | 2017-11-12T05:37:17.000Z | SNL|"Saturday Night Live"|"SNL Season 43"|"Epi... | 2103417 | 15993 | 2445 | 1970 | https://i.ytimg.com/vi/39idVpFF7NQ/default.jpg | False | False | False | Embattled Alabama Senate candidate Roy Moore (... | USA |
| 7 | nc99ccSXST0 | 17.14.11 | 5 Ice Cream Gadgets put to the Test | CrazyRussianHacker | 28 | 2017-11-12T21:50:37.000Z | 5 Ice Cream Gadgets|"Ice Cream"|"Cream Sandwic... | 817732 | 23663 | 778 | 3432 | https://i.ytimg.com/vi/nc99ccSXST0/default.jpg | False | False | False | Ice Cream Pint Combination Lock - http://amzn.... | USA |
| 8 | jr9QtXwC9vc | 17.14.11 | The Greatest Showman | Official Trailer 2 [HD]... | 20th Century Fox | 1 | 2017-11-13T14:00:23.000Z | Trailer|"Hugh Jackman"|"Michelle Williams"|"Za... | 826059 | 3543 | 119 | 340 | https://i.ytimg.com/vi/jr9QtXwC9vc/default.jpg | False | False | False | Inspired by the imagination of P.T. Barnum, Th... | USA |
| 9 | TUmyygCMMGA | 17.14.11 | Why the rise of the robots wonât mean the en... | Vox | 25 | 2017-11-13T13:45:16.000Z | vox.com|"vox"|"explain"|"shift change"|"future... | 256426 | 12654 | 1363 | 2368 | https://i.ytimg.com/vi/TUmyygCMMGA/default.jpg | False | False | False | For now, at least, we have better things to wo... | USA |
india = pd.read_csv("D:\Odin class\youtube/INvideos.csv", encoding = "ISO-8859-1")
country = []
for i in india["video_error_or_removed"]:
if i == "FALSE":
country.append("India")
else:
country.append("INDIA")
india["Country"] = country
india.head(3)
| video_id | trending_date | title | channel_title | category_id | publish_time | tags | views | likes | dislikes | comment_count | thumbnail_link | comments_disabled | ratings_disabled | video_error_or_removed | description | Country | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | kzwfHumJyYc | 17.14.11 | Sharry Mann: Cute Munda ( Song Teaser) | Parmi... | Lokdhun Punjabi | 1 | 2017-11-12T12:20:39.000Z | sharry mann|"sharry mann new song"|"sharry man... | 1096327 | 33966 | 798 | 882 | https://i.ytimg.com/vi/kzwfHumJyYc/default.jpg | False | False | False | Presenting Sharry Mann latest Punjabi Song Cu... | INDIA |
| 1 | zUZ1z7FwLc8 | 17.14.11 | पà¥à¤°à¤¿à¤¯à¤¡à¥à¤¸ à¤à¥ समय, प... | HJ NEWS | 25 | 2017-11-13T05:43:56.000Z | पà¥à¤°à¤¿à¤¯à¤¡à¥à¤¸ à¤à¥ समय|"प... | 590101 | 735 | 904 | 0 | https://i.ytimg.com/vi/zUZ1z7FwLc8/default.jpg | True | False | False | पà¥à¤°à¤¿à¤¯à¤¡à¥à¤¸ à¤à¥ समय, प... | INDIA |
| 2 | 10L1hZ9qa58 | 17.14.11 | Stylish Star Allu Arjun @ ChaySam Wedding Rece... | TFPC | 24 | 2017-11-12T15:48:08.000Z | Stylish Star Allu Arjun @ ChaySam Wedding Rece... | 473988 | 2011 | 243 | 149 | https://i.ytimg.com/vi/10L1hZ9qa58/default.jpg | False | False | False | Watch Stylish Star Allu Arjun @ ChaySam Weddin... | INDIA |
uk = pd.read_csv("D:\Odin class\youtube/GBvideos.csv", encoding = "ISO-8859-1")
country = []
for i in uk["video_error_or_removed"]:
if i == "FALSE":
country.append("United Kingdom")
else:
country.append("UK")
uk["Country"] = country
uk.head(1)
| video_id | trending_date | title | channel_title | category_id | publish_time | tags | views | likes | dislikes | comment_count | thumbnail_link | comments_disabled | ratings_disabled | video_error_or_removed | description | Country | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Jw1Y-zhQURU | 17.14.11 | John Lewis Christmas Ad 2017 - #MozTheMonster | John Lewis | 26 | 2017-11-10T07:38:29.000Z | christmas|"john lewis christmas"|"john lewis"|... | 7224515 | 55681 | 10247 | 9479 | https://i.ytimg.com/vi/Jw1Y-zhQURU/default.jpg | False | False | False | Click here to continue the story and make your... | UK |
yt_merge = pd.concat([usa, uk, india])
yt = yt_merge[['trending_date', 'category_id', 'tags', 'views', 'likes', 'dislikes', 'comment_count', 'description', 'Country']]
yt.to_csv (r'YouTube.csv', index = False, header=True)
yt = pd.read_csv("YouTube.csv", parse_dates=['trending_date'], engine='python', error_bad_lines=False)
yt.head()
C:\Users\Admin\AppData\Local\Temp\ipykernel_1388\1473296237.py:1: FutureWarning: The error_bad_lines argument has been deprecated and will be removed in a future version. Use on_bad_lines in the future.
yt = pd.read_csv("YouTube.csv", parse_dates=['trending_date'], engine='python', error_bad_lines=False)
| trending_date | category_id | tags | views | likes | dislikes | comment_count | description | Country | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 17.14.11 | 22 | SHANtell martin | 748374 | 57527 | 2966 | 15954 | SHANTELL'S CHANNEL - https://www.youtube.com/s... | USA |
| 1 | 17.14.11 | 24 | last week tonight trump presidency|"last week ... | 2418783 | 97185 | 6146 | 12703 | One year after the presidential election, John... | USA |
| 2 | 17.14.11 | 23 | racist superman|"rudy"|"mancuso"|"king"|"bach"... | 3191434 | 146033 | 5339 | 8181 | WATCH MY PREVIOUS VIDEO ⶠ\n\nSUBSCRIBE ⺠... | USA |
| 3 | 17.14.11 | 24 | rhett and link|"gmm"|"good mythical morning"|"... | 343168 | 10172 | 666 | 2146 | Today we find out if Link is a Nickelback amat... | USA |
| 4 | 17.14.11 | 24 | ryan|"higa"|"higatv"|"nigahiga"|"i dare you"|"... | 2095731 | 132235 | 1989 | 17518 | I know it's been a while since we did this sho... | USA |
yt.tail()
| trending_date | category_id | tags | views | likes | dislikes | comment_count | description | Country | |
|---|---|---|---|---|---|---|---|---|---|
| 117212 | 18.14.06 | 23 | twinkle vaishnav comedy|"twinkle vaishnav"|"tw... | 214378 | 3291 | 404 | 196 | PRG Music & RDC Rajasthani presents फà¥à¤à... | INDIA |
| 117213 | 18.14.06 | 24 | flowers serials|"actress"|"malayalam serials"|... | 406828 | 1726 | 478 | 1428 | Flowers - A R Rahman Show,Book your Tickets He... | INDIA |
| 117214 | 18.14.06 | 24 | mazhavil manorama|"bhramanam full episode"|"gt... | 386319 | 1216 | 453 | 697 | Subscribe to Mazhavil Manorama now for your da... | INDIA |
| 117215 | 18.14.06 | 24 | tarang|"tarang tv"|"tarang tv online"|"tarang ... | 130263 | 698 | 115 | 65 | Nuabohu : Story of a rustic village girl who w... | INDIA |
| 117216 | 18.14.06 | 24 | Ee Nagaraniki Emaindi|"Ee Nagaraniki Emaindi T... | 1278249 | 22466 | 1609 | 1205 | Check out Ee Nagaraniki Emaindi Trailer #EeNag... | INDIA |
yt.isnull().sum()
trending_date 0 category_id 0 tags 0 views 0 likes 0 dislikes 0 comment_count 0 description 1743 Country 0 dtype: int64
yt.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 117217 entries, 0 to 117216 Data columns (total 9 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 trending_date 117217 non-null object 1 category_id 117217 non-null int64 2 tags 117217 non-null object 3 views 117217 non-null int64 4 likes 117217 non-null int64 5 dislikes 117217 non-null int64 6 comment_count 117217 non-null int64 7 description 115474 non-null object 8 Country 117217 non-null object dtypes: int64(5), object(4) memory usage: 8.0+ MB
unique_categoriesid = yt['category_id'].unique()
print(unique_categoriesid, sep= "," )
[22 24 23 28 1 25 17 10 15 27 26 2 19 20 29 43 30]
yt['category_id'] = yt.category_id.replace("1", "Film & Animation")
yt['category_id'] = yt.category_id.replace("2", "Autos & Vehicles")
yt['category_id'] = yt.category_id.replace("10", "Music")
yt['category_id'] = yt.category_id.replace("15", "Pets & Animals")
yt['category_id'] = yt.category_id.replace("17", "Sports")
yt['category_id'] = yt.category_id.replace("19", "Travel & Events")
yt['category_id'] = yt.category_id.replace("20", "Gaming")
yt['category_id'] = yt.category_id.replace('22','People & Blogs')
yt['category_id'] = yt.category_id.replace("23", "Comedy")
yt['category_id'] = yt.category_id.replace("24","Entertainment")
yt['category_id'] = yt.category_id.replace("25", "News & Politics")
yt['category_id'] = yt.category_id.replace("26", "Howto & Style")
yt['category_id'] = yt.category_id.replace("27", "Education")
yt['category_id'] = yt.category_id.replace("28", "Science & Technology")
yt['category_id'] = yt.category_id.replace("29", "Nonprofits & Activism")
yt['category_id'] = yt.category_id.replace("30", "Movies")
yt['category_id'] = yt.category_id.replace("43", "Shows")
yt.head(5)
| trending_date | category_id | tags | views | likes | dislikes | comment_count | description | Country | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 17.14.11 | 22 | SHANtell martin | 748374 | 57527 | 2966 | 15954 | SHANTELL'S CHANNEL - https://www.youtube.com/s... | USA |
| 1 | 17.14.11 | 24 | last week tonight trump presidency|"last week ... | 2418783 | 97185 | 6146 | 12703 | One year after the presidential election, John... | USA |
| 2 | 17.14.11 | 23 | racist superman|"rudy"|"mancuso"|"king"|"bach"... | 3191434 | 146033 | 5339 | 8181 | WATCH MY PREVIOUS VIDEO ⶠ\n\nSUBSCRIBE ⺠... | USA |
| 3 | 17.14.11 | 24 | rhett and link|"gmm"|"good mythical morning"|"... | 343168 | 10172 | 666 | 2146 | Today we find out if Link is a Nickelback amat... | USA |
| 4 | 17.14.11 | 24 | ryan|"higa"|"higatv"|"nigahiga"|"i dare you"|"... | 2095731 | 132235 | 1989 | 17518 | I know it's been a while since we did this sho... | USA |
# Assuming you have a mapping of category IDs to category names
category_mapping = {
1: "Film & Animation",
2: "Autos & Vehicles",
10: "Music",
15: "Pets & Animals",
17: "Sports",
19: "Travel & Events",
20: "Gaming",
22: "People & Blogs",
23: "Comedy",
24: "Entertainment",
25: "News & Politics",
26: "Howto & Style",
27: "Education",
28: "Science & Technology",
29: "Nonprofits & Activism",
30: "Movies",
43: "Shows",
}
# Replace the 'category_id' values with corresponding category names
yt['category_id'] = yt['category_id'].replace(category_mapping)
# Display the DataFrame
print(yt.head(5))
trending_date category_id \
0 17.14.11 People & Blogs
1 17.14.11 Entertainment
2 17.14.11 Comedy
3 17.14.11 Entertainment
4 17.14.11 Entertainment
tags views likes \
0 SHANtell martin 748374 57527
1 last week tonight trump presidency|"last week ... 2418783 97185
2 racist superman|"rudy"|"mancuso"|"king"|"bach"... 3191434 146033
3 rhett and link|"gmm"|"good mythical morning"|"... 343168 10172
4 ryan|"higa"|"higatv"|"nigahiga"|"i dare you"|"... 2095731 132235
dislikes comment_count description \
0 2966 15954 SHANTELL'S CHANNEL - https://www.youtube.com/s...
1 6146 12703 One year after the presidential election, John...
2 5339 8181 WATCH MY PREVIOUS VIDEO ⶠ\n\nSUBSCRIBE ⺠...
3 666 2146 Today we find out if Link is a Nickelback amat...
4 1989 17518 I know it's been a while since we did this sho...
Country
0 USA
1 USA
2 USA
3 USA
4 USA
yt.head()
| trending_date | category_id | tags | views | likes | dislikes | comment_count | description | Country | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 17.14.11 | People & Blogs | SHANtell martin | 748374 | 57527 | 2966 | 15954 | SHANTELL'S CHANNEL - https://www.youtube.com/s... | USA |
| 1 | 17.14.11 | Entertainment | last week tonight trump presidency|"last week ... | 2418783 | 97185 | 6146 | 12703 | One year after the presidential election, John... | USA |
| 2 | 17.14.11 | Comedy | racist superman|"rudy"|"mancuso"|"king"|"bach"... | 3191434 | 146033 | 5339 | 8181 | WATCH MY PREVIOUS VIDEO ⶠ\n\nSUBSCRIBE ⺠... | USA |
| 3 | 17.14.11 | Entertainment | rhett and link|"gmm"|"good mythical morning"|"... | 343168 | 10172 | 666 | 2146 | Today we find out if Link is a Nickelback amat... | USA |
| 4 | 17.14.11 | Entertainment | ryan|"higa"|"higatv"|"nigahiga"|"i dare you"|"... | 2095731 | 132235 | 1989 | 17518 | I know it's been a while since we did this sho... | USA |
unique_categoriesid = yt['category_id'].unique()
print(unique_categoriesid)
['People & Blogs' 'Entertainment' 'Comedy' 'Science & Technology' 'Film & Animation' 'News & Politics' 'Sports' 'Music' 'Pets & Animals' 'Education' 'Howto & Style' 'Autos & Vehicles' 'Travel & Events' 'Gaming' 'Nonprofits & Activism' 'Shows' 'Movies']
# yt.dropna(inplace = True)
print(yt.isna().sum())
print(yt.shape)
trending_date 0 category_id 0 tags 0 views 0 likes 0 dislikes 0 comment_count 0 description 1743 Country 0 dtype: int64 (117217, 9)
yt.dropna(inplace = True)
print(yt.isna().sum())
print(yt.shape)
trending_date 0 category_id 0 tags 0 views 0 likes 0 dislikes 0 comment_count 0 description 0 Country 0 dtype: int64 (115474, 9)
from datetime import datetime
def changedate_formate(yt):
split = yt.split('.')
a = split[1]
b = split[2]
c = split[0]
''.join(a+b+c)
return
yt.info() #The trending date format can now be calculated
<class 'pandas.core.frame.DataFrame'> Int64Index: 115474 entries, 0 to 117216 Data columns (total 9 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 trending_date 115474 non-null object 1 category_id 115474 non-null object 2 tags 115474 non-null object 3 views 115474 non-null int64 4 likes 115474 non-null int64 5 dislikes 115474 non-null int64 6 comment_count 115474 non-null int64 7 description 115474 non-null object 8 Country 115474 non-null object dtypes: int64(4), object(5) memory usage: 8.8+ MB
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import plotly.offline as pyo
# Assuming yt is your DataFrame
fig = make_subplots()
for category_id, group in yt.groupby('category_id'):
fig.add_trace(go.Bar(
x=group['Country'],
y=group['likes'],
name=f'Category {category_id}'
))
fig.update_layout(
title="YouTube Videos User Engagement by Countries (Likes)",
barmode='overlay',
xaxis=dict(title='Country'),
yaxis=dict(title='Likes'),
legend=dict(title='Category'),
)
# Show the plot
pyo.plot(fig, filename='youtube_engagement.html')
import plotly.graph_objects as go
# Assuming yt is your DataFrame
fig = go.Figure()
for category_id, group in yt.groupby('category_id'):
fig.add_trace(go.Bar(
x=group['Country'],
y=group['likes'],
name=f'Category {category_id}'
))
fig.update_layout(
title="YouTube Videos User Engagement by Countries (Likes)",
barmode='overlay',
xaxis=dict(title='Country'),
yaxis=dict(title='Likes'),
legend=dict(title='Category'),
)
fig.show()
import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species", marginal_y="violin",
marginal_x="box", trendline="ols", template="simple_white")
fig.show()
px.bar(yt, x = "Country", y = "likes",color="category_id", barmode='overlay', title = "YouTube Videos User Engagement by Countries (Likes)")
px.bar(yt, x = "Country", y = "dislikes",color="category_id", barmode='overlay', title = "YouTube Videos User Engagement by Countries (Dislikes)")
import plotly.graph_objs as go
fig = px.bar(yt.head(), x='category_id', y='views', title='YouTube Videos Views by Category',
labels={'views': 'Number of Views', 'category_id': 'Video Category'},
color='category_id')
print(fig)
if isinstance(fig, go.Figure):
print("fig is a valid Plotly figure object.")
else:
print("fig is not a valid Plotly figure object.")
fig.show()
px.boxplot(yt, x = "Country", y = "comment_count", title = "YouTube Videos User Engagement by Countries (Comment Count)")
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import plotly.offline as pyo
# Assuming yt is your DataFrame
fig = make_subplots()
for category_id, group in yt.groupby('category_id'):
fig.add_trace(go.Bar(
x=group['Country'],
y=group['likes'],
name=f'Category {category_id}'
))
fig.update_layout(
title="YouTube Videos User Engagement by Countries (Likes)",
barmode='overlay',
xaxis=dict(title='Country'),
yaxis=dict(title='Likes'),
legend=dict(title='Category'),
)
# Show the plot
pyo.plot(fig, filename='youtube_engagement.html')
'youtube_engagement.html'
import plotly.offline as pyo
fig = px.bar(yt, x="Country", y="likes", color="category_id", barmode='overlay', title="YouTube Videos User Engagement by Countries (Likes)")
pyo.plot(fig, filename='yt_engagement.html')
'yt_engagement.html'
import plotly.express as px
import pandas as pd
# Assuming yt is your original DataFrame
# Creating a smaller subset, e.g., the first 100 rows
small_subset_yt = yt.head(100)
# Plotting with the smaller subset
fig = px.bar(small_subset_yt, x="Country", y="likes", color="category_id", barmode='overlay', title="YouTube Videos User Engagement by Countries (Likes)")
fig.show()
import plotly.offline as pyo
fig = px.bar(yt, x="Country", y="likes", color="category_id", barmode='group', title="YouTube Videos User Engagement by Countries (Likes)")
pyo.plot(fig, filename='yt_engagement.html')
# fig = px.bar(yt, x="Country", y="likes", color="category_id", barmode='group', title="YouTube Videos User Engagement by Countries (Likes)")
'yt_engagement.html'
import plotly.express as px
import pandas as pd
# Assuming yt is your original DataFrame
# Creating a smaller subset, e.g., the first 100 rows
small_subset_yt = yt.head(100)
# Plotting with the smaller subset
fig = px.bar(small_subset_yt, x="Country", y="likes", color="category_id", barmode='overlay', title="YouTube Videos User Engagement by Countries (Likes)")
fig.show()
import plotly.express as px
import pandas as pd
# Assuming yt is your DataFrame with multiple countries
# Creating a smaller subset, e.g., the first 100 rows
small_subset_yt = yt.head(100)
# Plotting with the smaller subset
fig = px.bar(small_subset_yt, x="Country", y="likes", color="category_id", barmode='overlay',
facet_col="Country", facet_col_wrap=5, # Adjust the wrap parameter as needed
title="YouTube Videos User Engagement by Countries (Likes)")
fig.show()
likes_by_category = yt.groupby('category_id')['likes'].sum().reset_index()
fig = px.bar(likes_by_category, x='category_id', y='likes', title='User Engagement by Category (Likes)',
labels={'likes': 'Total Likes', 'category_id': 'Category'})
# Show the plot
fig.show()
dislikes_by_category = yt.groupby('category_id')['dislikes'].sum().reset_index()
# Plotting the bar chart
fig = px.bar(dislikes_by_category, x='category_id', y='dislikes', title='User Engagement by Category (Dislikes)',
labels={'dislikes': 'Total Dislikes', 'category_id': 'Category'})
# Show the plot
fig.show()
# RESEARCH QUESTION 4. Which category has the highest number of user engagement on YouTube (comments)?
comments_by_category = yt.groupby('category_id')['comment_count'].sum().reset_index()
# Plotting the bar chart
fig = px.bar(comments_by_category, x='category_id', y='comment_count', title='User Engagement by Category (Comments)',
labels={'comment_count': 'Total Comments', 'category_id': 'Category'})
# Show the plot
fig.show()
trends_by_month = yt.groupby('trending_date').size().reset_index(name='total_trends')
# Plotting the bar chart
fig = px.bar(trends_by_month, x='trending_date', y='total_trends',
title='Total Trends by Month', labels={'total_trends': 'Total Trends', 'trending_month': 'Month'})
# Show the plot
fig.show()
conda install -c conda-forge wordcloud=1.6.0
Retrieving notices: ...working... done Collecting package metadata (current_repodata.json): ...working... done Solving environment: ...working... unsuccessful initial attempt using frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): ...working... failed Note: you may need to restart the kernel to use updated packages.
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): conda.anaconda.org:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/r/notices.json HTTP/1.1" 404 None DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/notices.json HTTP/1.1" 404 None DEBUG:urllib3.connectionpool:https://conda.anaconda.org:443 "GET /conda-forge/notices.json HTTP/1.1" 404 None DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/msys2/notices.json HTTP/1.1" 404 None DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): conda.anaconda.org:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): conda.anaconda.org:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/msys2/noarch/current_repodata.json HTTP/1.1" 304 0 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/noarch/current_repodata.json HTTP/1.1" 304 0 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/r/noarch/current_repodata.json HTTP/1.1" 304 0 DEBUG:urllib3.connectionpool:https://conda.anaconda.org:443 "GET /conda-forge/win-64/current_repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/r/win-64/current_repodata.json HTTP/1.1" 304 0 DEBUG:urllib3.connectionpool:https://conda.anaconda.org:443 "GET /conda-forge/noarch/current_repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/msys2/win-64/current_repodata.json HTTP/1.1" 304 0 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/win-64/current_repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): conda.anaconda.org:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): conda.anaconda.org:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): repo.anaconda.com:443 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/r/noarch/repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/msys2/win-64/repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/noarch/repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/msys2/noarch/repodata.json HTTP/1.1" 304 0 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/r/win-64/repodata.json HTTP/1.1" 304 0 DEBUG:urllib3.connectionpool:https://repo.anaconda.com:443 "GET /pkgs/main/win-64/repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:https://conda.anaconda.org:443 "GET /conda-forge/noarch/repodata.json HTTP/1.1" 200 None DEBUG:urllib3.connectionpool:https://conda.anaconda.org:443 "GET /conda-forge/win-64/repodata.json HTTP/1.1" 200 None CondaSSLError: Encountered an SSL error. Most likely a certificate verification issue. Exception: [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2576)
from wordcloud import WordCloud
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[4], line 1 ----> 1 from wordcloud import WordCloud ModuleNotFoundError: No module named 'wordcloud'
import pandas as pd
import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
import seaborn as sns
import warnings
from collections import Counter
import datetime
import wordcloud
import json
import sys
print(sys.executable)
C:\ProgramData\anaconda3\python.exe
pip install wordcloud
Requirement already satisfied: wordcloud in c:\programdata\anaconda3\lib\site-packages (1.9.3) Requirement already satisfied: numpy>=1.6.1 in c:\programdata\anaconda3\lib\site-packages (from wordcloud) (1.24.3) Requirement already satisfied: pillow in c:\programdata\anaconda3\lib\site-packages (from wordcloud) (9.4.0) Requirement already satisfied: matplotlib in c:\programdata\anaconda3\lib\site-packages (from wordcloud) (3.7.1) Requirement already satisfied: contourpy>=1.0.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib->wordcloud) (1.0.5) Requirement already satisfied: cycler>=0.10 in c:\programdata\anaconda3\lib\site-packages (from matplotlib->wordcloud) (0.11.0) Requirement already satisfied: fonttools>=4.22.0 in c:\programdata\anaconda3\lib\site-packages (from matplotlib->wordcloud) (4.25.0) Requirement already satisfied: kiwisolver>=1.0.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib->wordcloud) (1.4.4) Requirement already satisfied: packaging>=20.0 in c:\programdata\anaconda3\lib\site-packages (from matplotlib->wordcloud) (23.0) Requirement already satisfied: pyparsing>=2.3.1 in c:\programdata\anaconda3\lib\site-packages (from matplotlib->wordcloud) (3.0.9) Requirement already satisfied: python-dateutil>=2.7 in c:\programdata\anaconda3\lib\site-packages (from matplotlib->wordcloud) (2.8.2) Requirement already satisfied: six>=1.5 in c:\programdata\anaconda3\lib\site-packages (from python-dateutil>=2.7->matplotlib->wordcloud) (1.16.0) Note: you may need to restart the kernel to use updated packages.
# Hiding warnings for cleaner display
warnings.filterwarnings('ignore')
# Configuring some options
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
# If you want interactive plots, uncomment the next line
# %matplotlib notebook
#Basic configurations for improving visualization of graphs
PLOT_COLORS = ["#268bd2", "#0052CC", "#FF5722", "#b58900", "#003f5c"]
pd.options.display.float_format = '{:.2f}'.format
sns.set(style="ticks")
plt.rc('figure', figsize=(8, 5), dpi=100)
plt.rc('axes', labelpad=20, facecolor="#ffffff", linewidth=0.4, grid=True, labelsize=14)
plt.rc('patch', linewidth=0)
plt.rc('xtick.major', width=0.2)
plt.rc('ytick.major', width=0.2)
plt.rc('grid', color='#9E9E9E', linewidth=0.4)
plt.rc('font', family='Arial', weight='400', size=10)
plt.rc('text', color='#282828')
plt.rc('savefig', pad_inches=0.3, dpi=300)
india = pd.read_csv("D:\Odin class\youtube/INvideos.csv")
india.head()
| video_id | trending_date | title | channel_title | category_id | publish_time | tags | views | likes | dislikes | comment_count | thumbnail_link | comments_disabled | ratings_disabled | video_error_or_removed | description | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | kzwfHumJyYc | 17.14.11 | Sharry Mann: Cute Munda ( Song Teaser) | Parmi... | Lokdhun Punjabi | 1 | 2017-11-12T12:20:39.000Z | sharry mann|"sharry mann new song"|"sharry man... | 1096327 | 33966 | 798 | 882 | https://i.ytimg.com/vi/kzwfHumJyYc/default.jpg | False | False | False | Presenting Sharry Mann latest Punjabi Song Cu... |
| 1 | zUZ1z7FwLc8 | 17.14.11 | पीरियड्स के समय, पेट पर पति करता ऐसा, देखकर दं... | HJ NEWS | 25 | 2017-11-13T05:43:56.000Z | पीरियड्स के समय|"पेट पर पति करता ऐसा"|"देखकर द... | 590101 | 735 | 904 | 0 | https://i.ytimg.com/vi/zUZ1z7FwLc8/default.jpg | True | False | False | पीरियड्स के समय, पेट पर पति करता ऐसा, देखकर दं... |
| 2 | 10L1hZ9qa58 | 17.14.11 | Stylish Star Allu Arjun @ ChaySam Wedding Rece... | TFPC | 24 | 2017-11-12T15:48:08.000Z | Stylish Star Allu Arjun @ ChaySam Wedding Rece... | 473988 | 2011 | 243 | 149 | https://i.ytimg.com/vi/10L1hZ9qa58/default.jpg | False | False | False | Watch Stylish Star Allu Arjun @ ChaySam Weddin... |
| 3 | N1vE8iiEg64 | 17.14.11 | Eruma Saani | Tamil vs English | Eruma Saani | 23 | 2017-11-12T07:08:48.000Z | Eruma Saani|"Tamil Comedy Videos"|"Films"|"Mov... | 1242680 | 70353 | 1624 | 2684 | https://i.ytimg.com/vi/N1vE8iiEg64/default.jpg | False | False | False | This video showcases the difference between pe... |
| 4 | kJzGH0PVQHQ | 17.14.11 | why Samantha became EMOTIONAL @ Samantha naga ... | Filmylooks | 24 | 2017-11-13T01:14:16.000Z | Filmylooks|"latest news"|"telugu movies"|"telu... | 464015 | 492 | 293 | 66 | https://i.ytimg.com/vi/kJzGH0PVQHQ/default.jpg | False | False | False | why Samantha became EMOTIONAL @ Samantha naga ... |
india.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 37352 entries, 0 to 37351 Data columns (total 16 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 video_id 37352 non-null object 1 trending_date 37352 non-null object 2 title 37352 non-null object 3 channel_title 37352 non-null object 4 category_id 37352 non-null int64 5 publish_time 37352 non-null object 6 tags 37352 non-null object 7 views 37352 non-null int64 8 likes 37352 non-null int64 9 dislikes 37352 non-null int64 10 comment_count 37352 non-null int64 11 thumbnail_link 37352 non-null object 12 comments_disabled 37352 non-null bool 13 ratings_disabled 37352 non-null bool 14 video_error_or_removed 37352 non-null bool 15 description 36791 non-null object dtypes: bool(3), int64(5), object(8) memory usage: 3.8+ MB
india["description"] = india["description"].fillna(value="")
india.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 37352 entries, 0 to 37351 Data columns (total 16 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 video_id 37352 non-null object 1 trending_date 37352 non-null object 2 title 37352 non-null object 3 channel_title 37352 non-null object 4 category_id 37352 non-null int64 5 publish_time 37352 non-null object 6 tags 37352 non-null object 7 views 37352 non-null int64 8 likes 37352 non-null int64 9 dislikes 37352 non-null int64 10 comment_count 37352 non-null int64 11 thumbnail_link 37352 non-null object 12 comments_disabled 37352 non-null bool 13 ratings_disabled 37352 non-null bool 14 video_error_or_removed 37352 non-null bool 15 description 37352 non-null object dtypes: bool(3), int64(5), object(8) memory usage: 3.8+ MB
# Extract the year from the "trending_date" column using string manipulation
india["year"] = '20' + india["trending_date"].str[:2]
# Count the occurrences of each unique year
year_counts = india["year"].value_counts()
# Create a DataFrame from the Series
cdf = year_counts.reset_index()
# Rename the columns
cdf = cdf.rename(columns={"index": "year", "year": "No_of_videos"})
# Display the result
print("Years in which data was collected:")
print(cdf)
Years in which data was collected: year No_of_videos 0 2018 28293 1 2017 9059
import matplotlib.pyplot as plt
# Assuming you have already executed the previous code to create the 'cdf' DataFrame
# Bar plot
plt.figure(figsize=(10, 6))
plt.bar(cdf["year"], cdf["No_of_videos"], color='skyblue')
plt.title('Number of Videos Collected Each Year')
plt.xlabel('Year')
plt.ylabel('Number of Videos')
plt.show()
india.describe()
| category_id | views | likes | dislikes | comment_count | |
|---|---|---|---|---|---|
| count | 37352.00 | 37352.00 | 37352.00 | 37352.00 | 37352.00 |
| mean | 21.58 | 1060477.65 | 27082.72 | 1665.08 | 2677.00 |
| std | 6.56 | 3184932.05 | 97145.10 | 16076.17 | 14868.32 |
| min | 1.00 | 4024.00 | 0.00 | 0.00 | 0.00 |
| 25% | 23.00 | 123915.50 | 864.00 | 108.00 | 81.00 |
| 50% | 24.00 | 304586.00 | 3069.00 | 326.00 | 329.00 |
| 75% | 24.00 | 799291.25 | 13774.25 | 1019.25 | 1285.00 |
| max | 43.00 | 125432237.00 | 2912710.00 | 1545017.00 | 827755.00 |
We note from the table above that The average number of viewson a trending video is 1,060,477. The median value for the number of views is 304,586 , which means that half the trending videos have views that are less than that number, and the other half have views larger than that number. The average number of likes on a trending video is 27,082 , while the average number of dislikes is 1,665. The average comment count is 2,677 while the median is 329.
import matplotlib.pyplot as plt
# Assuming you have a DataFrame named 'df'
# and the "views" column contains numerical data
# Specify the bin edges for the histogram
bin_edges = range(0, int(india["views"].max()) + 10000000, 10000000)
# Plot the histogram
plt.figure(figsize=(10, 6))
plt.hist(india["views"], bins=bin_edges, color='skyblue', edgecolor='black')
plt.title('Distribution of Views in Video Data')
plt.xlabel('Number of Views')
plt.ylabel('Number of Videos')
plt.xticks(bin_edges) # Set x-axis ticks to match bin edges
plt.show()
plt.rc('figure.subplot', wspace=0.9)
fig, ax = plt.subplots()
_ = sns.distplot(india["likes"], kde=False,
color=PLOT_COLORS[4], hist_kws={'alpha': 1},
bins=np.linspace(0, 6e6, 61), ax=ax)
_ = ax.set(xlabel="Likes", ylabel="No. of videos")
_ = plt.xticks(rotation=90)
fig, ax = plt.subplots()
_ = sns.distplot(india[india["likes"] <= 1e5]["likes"], kde=False,
color=PLOT_COLORS[4], hist_kws={'alpha': 1}, ax=ax)
_ = ax.set(xlabel="Likes", ylabel="No. of videos")
fig, ax = plt.subplots()
_ = sns.distplot(india["comment_count"], kde=False, rug=False,
color=PLOT_COLORS[4], hist_kws={'alpha': 1}, ax=ax)
_ = ax.set(xlabel="Comment Count", ylabel="No. of videos")
def contains_capitalized_word(s):
for w in s.split():
if w.isupper():
return True
return False
india["contains_capitalized"] = india["title"].apply(contains_capitalized_word)
value_counts = india["contains_capitalized"].value_counts().to_dict()
fig, ax = plt.subplots()
_ = ax.pie([value_counts[False], value_counts[True]], labels=['No', 'Yes'],
colors=[PLOT_COLORS[4], '#ffa600'], textprops={'color': '#040204'}, startangle=45)
_ = ax.axis('equal')
_ = ax.set_title('Capitalized Word?')